package main

import (
	"crypto/md5"
	"encoding/hex"
)

func getMd5String(text string) (string, error) {
	md5Ctx := md5.New()
	_, err := md5Ctx.Write([]byte(text))
	if err != nil {
		return "", err
	}

	cipherBytes := md5Ctx.Sum(nil)
	return hex.EncodeToString(cipherBytes), nil
}

func getMd5Bytes(data []byte) ([]byte, error) {
	md5Ctx := md5.New()
	_, err := md5Ctx.Write(data)
	if err != nil {
		return nil, err
	}
	cipherBytes := md5Ctx.Sum(nil)
	return cipherBytes, nil
}